Electricity Volatility Quant Model
Preface
The following trading strategy is an extension of my previous project (in collaboration with Olivier Haley) regarding the use of batteries and their profitability on the Australian power grid. The purpose is to take our initial findings and take a different approach while applying structured quantitative processes to improve and enhance the results. I have opted to look at a modeling structure that has the ability to capture the power of volatility that occurs in pricing in order to capitalize on price movements at the optimal time. Our previous apporach relied solely on time of day. I now want to look at how I can use volatility analysis to potentially increase the profitability of the algorithm. For a detailed explanation of the Australian power grid, please refer to the AEMC. This project will not go into as much depth explaining the grid system and pricing dynamics as our previous work. For access to that information, please visit github.
Data Provided
CETF provided us with the following datasets:
- Real-time 5 minute wholesale price data for 2015 - 2022.
- Pre-dispatch prices for 2022. These prices are published up to 48 hours prior to the current time. These prices reflect expected bidding behaviour of generators in the market taking into account expected demand, temperatures, network constraints, etc.
- Actual operational demand 2022. This value is only known after the demand has occurred and settled prices are published.
- Forcasted Demand at the 10%, 50% and 90% confidence levels. These forcasted values take into account a multitude of factors such as weather, grid congestion and historical demand trends.
Rationale
The approach taken involves looking at how volatility in electricity prices varies throughout the day on the grid in New South Wales. This approach requires an understanding of the ‘Bathtub Curve’, or how prices follow a similar pattern during the day due to demand. This idea is depicted below:
Now lets look at some actual data that we have that shows how the price reflects the concept touched on in the image above. Here is a price plot from the same day of 4 months, each pertaining to a different season. The value for month is the respective month of the year.
Note that the bathtub shape is present, but it is clearly more visable in July (winter in Australia). The prominence of the shape fades away as you approach summer. This highlights the idea that there is seasonality present in price volatility. Our previous model performed very well in the winter months, and this plot highlights the main reason why.
To further look into this, I threw on a rolling average standard deviation, broken down by season:
Here again you can clearly see that there is seasonality in volatility. The winter season is highly volatile in comparison to the summer, but the idea that volatility increases during peak demand hours is very much still visable. There is also both weekly and daily seasonality present, which is highlighted in the chart below, generated from Facebooks Prophet Model:
Note the patterns here:
- There is a clear annual seasonality effect between winter and summer.
- Weekly seasonality sees fluctuations between weekdays and weekends.
- Daily seasonality follows the bathtub curve.
From a high level, these trends make sense if you think about them from the perspective of demand. The issue now becomes how to keep this seasonality in mind when producing trading signals. There will need to be variability in signal generation on a daily, weekly, and annual level. This was a downfall of the previous model, and an area that I am trying to improve on with this optimization model. The reason for performing this analysis was to drive home that point heading into the next step, which is figuring out how to use volatility to trade on the grid and optimize the usage of the battery.
Taking A Look At Volatility: Stochastic Time Series Volatility and GARCH models.
Stochastic volatility models and GARCH (Generalized Autoregressive Conditional Heteroskedasticity) models are particularly useful in analyzing electricity prices due to the inherently volatile nature of energy markets. These models excel at capturing the dynamic behavior of volatility through time.
Stochastic volatility models allow for a random process to govern the variance of price changes, which can capture the unpredictability and potential heavy tails often observed in electricity price distributions. They are flexible in modeling the volatility’s evolution and can account for shocks that persist over time, which is crucial for markets that can be influenced by unpredictable events like changes in supply and demand, regulatory shifts, or varying weather conditions.
GARCH models, on the other hand, are adept at modeling the conditional variance based on past squared residuals and past variances, making them highly effective for time series where volatility clustering occurs. This is a common feature in electricity markets, where periods of high volatility are often followed by low volatility and low by high. This autoregressive approach helps in forecasting future volatility based on the observed patterns.
I initially took stabs at stochastic modelling process both with use of a Hidden Markov (MwSM package) to implement any regime switching properties, as well as forecasting volatility using Bayesian implementations to model heteroskedasticity (Stochvol package). Below is the output of my estimated volatilities from different posterior quantiles, with a forecast tagged on the front:
The above plot depicts two things:
- It effectively shows me nothing and does a poor job of forecasting.
- It made me come to the realization that I am missing key components in my statistical knowledge base to properly engineer the data before implementing these stochastic processes.
I ran into the same issue running my Markov Models. My feature engineering to set up the variables in such a way that allows the model to produce meaningful output was not sophisticated enough to suffice. This is due in part to the complexity of the problem I am trying to solve with electricity data, as well as the reasons highlighted in the following paragraph.
Stochastic models are complex and can be challenging to set up due to their intrinsic reliance on random processes and the intricate mathematical frameworks they employ. They require a deep understanding of probability theory and stochastic calculus to accurately model the random behavior of variables over time. Setting up data for these models involves not just extensive preprocessing to ensure quality and relevance but also sophisticated techniques to estimate and calibrate the numerous parameters that govern the random processes. This is where I am severely lacking the capability at my current stage in personal development to accurately tackle something of this nature. Additionally, stochastic models must be carefully validated and their assumptions tested against empirical data, which can be a non-trivial, data-intensive endeavor.
The GARCH models were producing statistically insignificant outputs, and trying to use GARCH to forecast volatility given the nature of how prices change so drastically and frequently in my data led to implementation issues and feasibility problems that were outside the scope of my timeline to fix.
The process of working through, attempting, and failing on the above models allowed me to grow drastically, and I look forward to successfully tackling them in the future.
This led me to come up with an idea, that quite frankly I know won’t be very successful, but it allows me to explore the answers to these questions:
-Why are industry professionals using stochastic models for battery optimization?
-What are the things to look for in a basic volatility model that could be improved by a stochastic process?
I went back to the drawing board to try and find answers. Moving forward, I made sure that my model relied on the following:
- I know the grid switches from high vol states to low vol states.
- I know there is seasonality and this will have an effect on these states, their magnitude, and the probability of them switching.
- My results, if broken down and optimized differing by season and relying solely on volatility signals, should produce different results for each season and (consequently due to my analysis lacking regime switching probabilities and diffusion processes) produce better results in high vol states and lackluster results in low vol states.
The rest of the document and the model that follows aims to provide insight into these points.
Volatility Analysis
My return data was split into seasons (Winter, Spring, Summer, Fall), utilizing 2022 as the period. I am okay with running the model sub-setted like this because the data is so high frequency, and the grid itself switched to 5 minute pricing in late 2021. This period ensures there was no regulatory change and I have access to data from every season.
I ran rolling standard deviations on an initial window size of 2 hours. The thought process here is the average rolling volatility will capture spikes as the window rolls into the high vol zones, and start to drop when it rolls into low vol zones. This parameter will be part of my optimization process. This is in essence trying to capture what the stochastic models are made for: To detect when the market switches regimes from times of high volatility to low volatility. In abcence of a working stochastic model, this was the approach I came up with to get a working analysis that I can iterate over and optimize the parameters for.
Strategy and Signals
My strategy will consist of charge and discharge signals based on the rolling volatility of relative price changes, which aligns with the analysis and visuals above. There are clearly periods of higher vol throughout the day when prices spike, which also vary in magnitude by season. This is why I will separately optimize the following parameters for each season:
- Rolling standard deviation window size.
- Percentile threshold to initiate buy and sell signals.
- Optimize parameters separately for each season.
My approach will be to buy when volatility is low (as prices are generally low, seen in the plots above) and sell when volatility is high (as prices are generally higher during the high vol clusters). Where our previous model focused solely on average price over time to generate signals, I am now focusing on using volatility and differentiating by season.
Constraints
To ensure proper implementation of the strategy, the following battery constraints need to be recognized in the algorithm:
- Size: 5.00 MW
- Power: 4 hour
- Capacity: 20.00 MWh (Size*Power)
- Max ramp rate: 0.417 MW/5 minutes (discharge and recharge)
- Maximum DOD (Depth of Discharge): 1.00
- Minimum DOD (Depth of Discharge): 0.00
- Maximum average cycles per day: 1.75 cycles (1 cycle equals 4 hours of discharge and 4 hours of discharge)
- Maximum Operating Hours: 14.00 hours
- Ability to change status every 5 minutes: charge, discharge, idle.
- Prices: NEM wholesale prices charged when charging from the NEM, and NEM prices are earned when discharging to the NEM.
Strategy
The strategy implemented is a quantitative trading approach that capitalizes on the fluctuating electrcity market by leveraging the storage capabilities of the battery. The core of the strategy revolves around the concept of buying and storing energy when prices are lower and selling energy when prices are higher, effectively attempting to ‘buy low, sell high’ on a granular, intra-day timescale.
The operational logic of the strategy is governed by a predictive model that utilizes the rolling standard deviation of energy price changes—a measure of market volatility—as a signal for trading opportunities. When market volatility is below a specified percentile threshold, the model perceives this as a stable, low-price opportunity to charge the battery (buy energy). Conversely, when volatility is above a higher percentile threshold, it interprets this as a volatile, high-price scenario to discharge the battery (sell energy). The strategy ensures that the battery operates within its physical and operational constraints, notably the maximum state of charge (SOC), the minimum SOC, and the maximum number of charge-discharge cycles allowed per day.
Optimization of the strategy is multi-faceted, focusing primarily on the parameters that define the volatility thresholds for buying and selling. The objective is to fine-tune these thresholds to maximize return while adhering to the battery’s cycle considerations and the operational limitations imposed by the trading intervals. By systematically adjusting the standard deviation windows and quantile thresholds, the strategy seeks to identify the optimal balance between responsiveness to market conditions and the constraints of the battery system, enhancing profitability while remaining within the constraints of the trading operations. The outcome of this optimization process is intended to refine the model for performance across all four seasons, as optimization has been subset and ran for winter, summer, spring and fall. This means the model will be trained four different times to optimize the parameters across the seasons, and then tested on the corresponding season within the testing data.
Training and Testing Data
The model will be ran on the following timelines for training and testing:
- Training: 2022 (seasons trained separately)
- Testing: 2023 (seasons tested separately)
Australia is in the southern hemisphere, so the seasons are broken down as follows:
- Summer (December, January, February)
- Fall (March, April, May)
- Winter (June, July, August)
- Spring (September, October, November)
Cumulative equity will be recalculated when the data is combined together. The reason for this is due to the seasons overlapping with what would normally be a change in the year. Cumulative equity will be calculated as if the strategy were to start January 1st for both the training and testing sets.
Optimization
My parameters were optimized over 539 different combinations for each season, consisting of the following ranges:
- Rolling SD window from 50 minutes to 2.5 hours.
- Low vol buy quantiles set at a range of the 15th percentile to the 45th percentile.
- High vol sell quantiles set at a range of the 60th percentile to the 90th percentile.
The value that is being optimized for is strictly cumulative equity. The reasoning behind this approach is that the goal of this model is to align with the goal of CETF. They want these batteries to make money on the grid. The constraints of the battery inherently handle drawdowns and capital allocation and position sizes are handled by the maximum ramp rate of the battery. We can only buy as fast as the battery can charge, and can only sell as fast as the battery can discharge. This is implemented in the logic, and is why the only factor being analyzed during optimization is total profit throughout each season.
To illustrate the results of optimization, I’ll show the two parameters that had the most variable effect on cumulative equity, broken down by season. The below plots are 3 dimensional surface charts that show how cumulative equity changes across the rolling standard deviation (volatility) window and the buy signal quantile, with the optimal sell signal:
The profit variability is much more drastic for the high vol seasons (fall and winter) in comparison to the low vol seasons (spring and summer). This is to be expected as previously discussed. A volatility strategy is going to capture more profit and be much more variable and sensitive to parameter changes in periods of high volatility.
Below is a table highlighting the optimal parameters, as seen on the surfaces above:
| sd_window | sd_buy_percentile | sd_sell_percentile | cumeq | season |
|---|---|---|---|---|
| 30 | 0.40 | 0.6 | 16167.437 | spring |
| 28 | 0.20 | 0.6 | 6419.396 | summer |
| 10 | 0.45 | 0.6 | 89742.675 | fall |
| 12 | 0.30 | 0.6 | 63444.525 | winter |
Note that the sell quantile is the same for each season, asking for signals to be generated when volatility levels are above the 60% percentile. This is concerning, and will be discussed further in the learnings and findings portion of the document.
Now that the optimal parameters have been discovered through iterating the model over different combinations, it is time to apply them to the model and run it on the testing data.
Results
Below shows a plot of the results of the model for each season:
The above plot highlights a few key factors:
- I lose money in the low volatility seasons (spring and summer)
- I am making money in the high volatility seasons (fall and winter)
The profitability during high volatility seasons like fall and winter can be attributed to larger price swings which present more opportunities for arbitrage; the battery storage system can capitalize on these fluctuations by buying energy when prices are low and selling when they are high. Conversely, during low volatility seasons such as spring and summer, the price movements are less pronounced, resulting in fewer opportunities to exploit the differentials.
Optimizing for each season individually may not fully mitigate this issue as my model relies solely on volatility to generate trading signals. If the underlying market conditions change states, for instance from high to low volatility, a model that doesn’t adapt to these changes may not perform well.
Here is a plot that depicts total cumulative equity across the entire year:
This shows exactly what the prior plot was depicting; I make steady profit throughout the fall and winter, and lose it in the spring and summer. The model itself generates a total cumulative profit of just under $30,000 AUD. This is disheartening, and is nowhere near the amount of profit needed to cover the infrastructure costs of these batteries to make the investment worthwhile.
There is one positive that comes out of this though, which is highlighted in the chart below:
Throughout the year, the average daily cycles are nowhere near reaching the capacity of 1.75 per day. Why is this a positive? Our previous model was very profitable, but did not exhaust the daily cycling capacity, meaning there is room to accommodate additional trading strategies without risking battery overuse. If We could find a way to implement additional signals in our previous model in relation to volatility that initiate trades to use up more of the capacity and make the model more profitable, this would add value, complexity, and ensure we are utilizing the battery to it’s full potential.
Learnings and Findings
As explained above, my model did in fact answer the questions I laid out. The reason is the lack of model sophistication is impacting it’s ability to properly detect the states of the market. Integrating a stochastic process into the trading strategy would provide a more dynamic model that recognizes and adjusts to changing market states. Stochastic models can incorporate random variables and probabilities that reflect the unpredictability of markets. By using stochastic calculus, you can model various market conditions and transition probabilities, allowing for more nuanced and responsive strategies. These could include mean-reverting processes during stable periods, and more trend-following or momentum-based processes during volatile periods, ensuring the strategy is tailored to the prevailing market state and can adapt as it evolves. My model does not have the ability to do this.
My logic also appears to have a fatal flaw. The sell percentile signal, over the course of optimization, does not change. After hours of debugging and redesigning the logic, the same problem persisted. I know this can’t possibly be attributable to market conditions, and is a fault in my programming. I just let the model pinpoint one SD sell signal, and looked at the variations in the other two variables (hence the surface diagrams).
The journey of refining my trading model has been both challenging and enlightening. Encountering the shortfalls of the current model—particularly its underperformance during low volatility seasons—has provided invaluable lessons on the complex dynamics of energy markets. Despite these hurdles, the deep-dive into the realm of stochastic models has been incredibly rewarding. It has not only broadened my understanding of market behavior but also fueled an interest in the predictive power of stochastic processes. This exploration into more advanced models, which account for the probabilistic nature of market states, has opened up new avenues for strategy development. It’s clear that while the model may not have met all expectations, the research and iterative process of model improvement and what is used in practice has been time well spent, laying the groundwork for more robust and adaptive strategies in the future.
Electricity markets are incredibly complex, and this is the hardest problem I have ever tried to solve. I look forward to continuing to grow my abilities to the point where I can implement enterprise-level models in this space, and take what I have learned throughout this process to position myself well for success. My knowledge base of electricity grids and their financial implications, battery storage and utilization, and stochastic models has grown immensely. This problem will only continue to become more prominent in the future, and I am excited to say I have been able to dip my toes in it.